unit banco;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Provider, SqlExpr, DB, DBClient, DBLocal, DBLocalS, StdCtrls,
  Mask, DBCtrls, ExtCtrls, Buttons;

type
  TfrmBanco = class(TForm)
    cdsBanco: TSQLClientDataSet;
    sBanco: TDataSource;
    cdsBancoID_BANCO: TSmallintField;
    cdsBancoBANCO: TStringField;
    cdsBancoSUCURSAL: TStringField;
    cdsBancoDOMICILIO: TStringField;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    Label4: TLabel;
    DBEdit4: TDBEdit;
    cdsBancoID_LOCALIDAD: TIntegerField;
    cdsLocalidad: TSQLClientDataSet;
    cdsLocalidadID_LOCALIDAD: TIntegerField;
    cdsLocalidadLOCALIDAD: TStringField;
    cdsBancolocalidad: TStringField;
    Label5: TLabel;
    DBLookupComboBox1: TDBLookupComboBox;
    SpeedButton1: TSpeedButton;
    Panel1: TPanel;
    DBNavigator1: TDBNavigator;
    procedure cdsBancoNewRecord(DataSet: TDataSet);
    procedure cdsBancoAfterPost(DataSet: TDataSet);
    procedure SpeedButton1Click(Sender: TObject);
  private
    Fusuario: word;
    FidBanco: integer;
    procedure Setusuario(const Value: word);
    procedure SetidBanco(const Value: integer);
  published
    property usuario: word read Fusuario write Setusuario;
    property idBanco: integer read FidBanco write SetidBanco;
  public
    constructor AltaModifBanco(AOwner: TComponent; usuario: word; id: integer);
  end;

var
  frmBanco: TfrmBanco;

implementation

uses MDatos, Recursos, abm;

{$R *.dfm}

constructor TfrmBanco.AltaModifBanco(AOwner: TComponent; usuario: word; id: integer);
begin
  inherited Create(Aowner);
  self.usuario := usuario;
  //self.idBanco := id;
  //self.cdsBanco.Params [0].AsInteger := self.idBanco;
  self.cdsBanco.Open;
  self.ShowModal;
end;

procedure TfrmBanco.cdsBancoNewRecord(DataSet: TDataSet);
begin
  self.cdsBancoID_BANCO.AsInteger :=  id('BANCO_GEN');
  if self.cdsBancoID_BANCO.AsInteger = 0 then
    self.cdsBanco.Cancel;
end;

procedure TfrmBanco.SetidBanco(const Value: integer);
begin
  FidBanco := Value;
end;

procedure TfrmBanco.Setusuario(const Value: word);
begin
  Fusuario := Value;
end;

procedure TfrmBanco.cdsBancoAfterPost(DataSet: TDataSet);
begin
  self.cdsBanco.ApplyUpdates(0);
end;

procedure TfrmBanco.SpeedButton1Click(Sender: TObject);
begin
    TfrmABM.Entrar(self, self.usuario, 1)
end;

end.
